package com.ebeijia.service.admin.impl;

import com.ebeijia.dto.PaymentDto;
import com.ebeijia.mybatis.mapper.OrderInfoMapper;
import com.ebeijia.query.OrderQuery;
import com.ebeijia.service.admin.OrderInfoService;
import com.ebeijia.util.DateUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;

/**
 * Created by YPJ on 2016/5/18.
 */
@Service
public class OrderInfoServiceImpl implements OrderInfoService {
    @Resource
    private OrderInfoMapper orderInfoMapper;
    @Override
    public List<PaymentDto> selectPayList(OrderQuery orderQuery) {
        List<PaymentDto> paymentDtoList = orderInfoMapper.selectPayList(orderQuery);
        BigDecimal bigDecimal = new BigDecimal("100");
        for(PaymentDto paymentDto:paymentDtoList){
            paymentDto.setTotalFee(paymentDto.getTotalFee().divide(bigDecimal,2,BigDecimal.ROUND_HALF_EVEN));
            paymentDto.setPayTime(DateUtil.formateStringDate(paymentDto.getPayTime()));
        }
        return paymentDtoList;
    }

    @Override
    public int selectPayCount(OrderQuery orderQuery) {
        return orderInfoMapper.selectPayCount(orderQuery);
    }
}
